package com.fzb.forum4j.po;

import java.io.File;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;


@Entity 
@DynamicUpdate(false)
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class CommonArea {

	@Id
    @GeneratedValue(generator = "increment") 
	@GenericGenerator(name = "increment", strategy = "increment") 
	private int cid;
	public File getImgFile() {
		return imgFile;
	}
	public void setImgFile(File imgFile) {
		this.imgFile = imgFile;
	}
	public String getImgFileFileName() {
		return imgFileFileName;
	}
	public void setImgFileFileName(String imgFileFileName) {
		this.imgFileFileName = imgFileFileName;
	}
	public String getImgFileContentType() {
		return imgFileContentType;
	}
	public void setImgFileContentType(String imgFileContentType) {
		this.imgFileContentType = imgFileContentType;
	}
	private String title;
	@Column(columnDefinition="TEXT") 
	private String content;
	private int views;
	private String keywords;
	private Boolean isRecommend;
	private Date pubTime;
	@Transient
	private Integer commentPage;
	
	@Transient
	private File imgFile;
	
	@Transient
	private String imgFileFileName;
	
	@Transient
	private String imgFileContentType;
 
 
	
	@ManyToOne
	@JoinColumn(name="userId")
	private User user;
	public int getCid() {
		return cid;
	}
	public void setCid(int cid) {
		this.cid = cid;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
 
 
	public String getKeywords() {
		return keywords;
	}
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
 
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Date getPubTime() {
		return pubTime;
	}
	public void setPubTime(Date pubTime) {
		this.pubTime = pubTime;
	}
	public int getViews() {
		return views;
	}
	public void setViews(int views) {
		this.views = views;
	}
	public Boolean getIsRecommend() {
		return isRecommend;
	}
	public void setIsRecommend(Boolean isRecommend) {
		this.isRecommend = isRecommend;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}

	public Integer getCommentPage() {
		if(commentPage==null){
			return 1;
		}
		else if(commentPage<1){
			return 1;
		}
		return commentPage;
	}
	public void setCommentPage(Integer commentPage) {
		this.commentPage = commentPage;
	}

 
	 
}
